package com.justyh.ssm.service.impl;

import com.justyh.ssm.model.User;
import com.justyh.ssm.service.ExcelService;
import com.justyh.ssm.service.UserService;
import com.justyh.ssm.util.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by Chejianer on 2016/9/2.
 */
@Service
public class ExcelServiceImpl implements ExcelService{

    @Autowired
    private UserService userService;
    public void toOutExcel(HttpServletResponse response,List<User> userList) {

        //ArrayList<User> userList=(ArrayList<User>) userService.getAllUser();
        //String headers[]={"序号","姓名","手机号","邮箱","密码","MD5盐","创建时间","修改时间","是否删除？"};
        //ExcelUtil.excelOut(response,userList,headers);

       String fileName="用户表";
       // List<User> userList=userService.getAllUser();
        String[] columnArr={"序号","姓名","手机号","邮箱"};
        String[] filedNameArr={"id","userName","userPhone","userEmail"};

        ExcelUtil.excelOut(fileName,columnArr,filedNameArr,userList,response);



    }
}
